Document that `cargo test` only compiles example
authorAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 17 Feb 2017 07:04:30 +0000 (10:04 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 17 Feb 2017 07:04:30 +0000 (10:04 +0300)
src/bin/test.rs
tests/test.rs

index 0dbe81f3d57f0cbbbace840a8e245fc39646c66c..afd482cd68ce5f421905dee6f2766866aedcd46b 100644 (file)
@@ -42,7 +42,7 @@ Options:
     --lib                        Test only this package's library
     --doc                        Test only this library's documentation
     --bin NAME ...               Test only the specified binaries
-    --example NAME ...           Test only the specified examples
+    --example NAME ...           Check that the specified examples compile
     --test NAME ...              Test only the specified integration test targets
     --bench NAME ...             Test only the specified benchmark targets
     --no-run                     Compile, but don't run tests
index c6c18b1f29bb83f9d90fa0b8c55991fc57e32fee..5102bca446e92b81245a8473f6c14aaa1d84f2cd 100644 (file)
@@ -2572,25 +2572,6 @@ fn doctest_only_with_dev_dep() {
                 execs().with_status(0));
 }
 
-#[test]
-fn test_can_test_example() {
-    let p = project("foo")
-        .file("Cargo.toml", r#"
-            [project]
-            name = "foo"
-            version = "0.1.0"
-        "#)
-        .file("examples/ex.rs", r#"
-            fn main() {}
-            #[test] fn kaboom() { panic("KABOOM!") }
-        "#);
-    let _ = p;
-// FIXME: does not work
-//    assert_that(p.cargo_process("test").arg("--example").arg("ex"),
-//                execs().with_status(101).with_stdout_contains("KABOOM!"))
-
-}
-
 #[test]
 fn test_many_targets() {
     let p = project("foo")
@@ -2629,10 +2610,10 @@ fn test_many_targets() {
             #[test] fn test_b() {}
         "#)
         .file("tests/c.rs", r#"
-            #[test] fn test_c() { panic!(); }
+            does not compile
         "#);
 
-    assert_that(p.cargo_process("test")
+    assert_that(p.cargo_process("test").arg("--verbose")
                     .arg("--bin").arg("a").arg("--bin").arg("b")
                     .arg("--example").arg("a").arg("--example").arg("b")
                     .arg("--test").arg("a").arg("--test").arg("b"),
@@ -2642,8 +2623,6 @@ fn test_many_targets() {
                     .with_stdout_contains("test bin_b ... ok")
                     .with_stdout_contains("test test_a ... ok")
                     .with_stdout_contains("test test_b ... ok")
-// FIXME: does not work
-//                  .with_stdout_contains("test example_a ... ok")
-//                  .with_stdout_contains("test example_b ... ok")
-    )
+                    .with_stderr_contains("[RUNNING] `rustc --crate-name a examples[/]a.rs [..]`")
+                    .with_stderr_contains("[RUNNING] `rustc --crate-name b examples[/]b.rs [..]`"))
 }